//index.js
//获取应用实例
var app = getApp()
const DB = wx.cloud.database();
const userInfo = DB.collection("UserInfo");

Page({
  data: {
    NAME : "点击刷新",
    HEADIMG : "/images/微信.png"
    
  },
  onLoad: function () {
    // console.log(app.globalData.userId)
    console.log("12")

  },
  jumpUserLogin:function(){
    wx.navigateTo({
      url: '/pages/index/index',
    })
  },
  myShare:function(){
    wx.navigateTo({
      url: '/pages/share/share',
    })
  }
  ,
  jumpFormulate:function(){
    wx.navigateTo({
      url: '/pages/formulate/formulate',
    })
  },
  jumpPerInfo:function(){
    wx.navigateTo({
      url: '/pages/perInfo/perInfo',
    })
  },
  jumproot:function(){
    wx.navigateTo({
      url: '/pages/managePWD/managePWD',
    })
  }
  ,
  refresh(){
    let that = this
    let id = app.globalData.userId

    if(id == ""){
      that.setData({
        NAME : "点击刷新"
      })
      wx.showToast({
        title: '请先登录账号！！',
        icon:"none"
      })

    }
    else{
      userInfo.where({
        _id : id
      }).get().then(res => {
        console.log(res)
        let info = res.data
        that.setData({
          NAME : info[0].userName,
          HEADIMG : info[0].headImg
        })
      })
    }

    
   
  }
  
})
